<template>
  <div class="app-container">
    <template>
      <div class="right-detail">
        <!-- 顶部查询表单 -->
        <div class="cbox">
          <el-form class="form" :model="flt" :inline="true" ref="fltForm">
            <el-form-item size="mini" label="需求编号:" prop="demandCode">
              <el-input clearable maxlength="20" v-model="flt.demandCode" size="mini" style="width: 180px"></el-input>
            </el-form-item>

            <el-form-item size="mini" label="需求状态:" prop="status">
              <el-select v-model="flt.status" clearable style="width: 180px">
                <el-option v-for="(item, index) in demandStatus" :key="index" :label="item.rvCmeaning" :value="item.rvLowValue"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item size="mini" label="起始地:" prop="site">
              <el-input clearable maxlength="20" v-model="flt.site" size="mini" style="width: 180px"></el-input>
            </el-form-item>
            <el-form-item size="mini" label="目的地:" prop="destination">
              <el-input clearable maxlength="20" v-model="flt.destination" size="mini" style="width: 180px"></el-input>
            </el-form-item>
            <el-form-item size="mini" prop="submitStartTime" label="提交时间:">
              <el-date-picker
                size="mini"
                value-format="yyyy-MM-dd"
                v-model="flt.submitStartTime"
                type="date"
                placeholder="请选择开始时间"
                style="width:180px;"
              ></el-date-picker
              >—
              <el-date-picker
                size="mini"
                value-format="yyyy-MM-dd"
                v-model="flt.submitEndTime"
                type="date"
                placeholder="请选择结束时间"
                style="width:180px;"
              ></el-date-picker>
            </el-form-item>
            <el-form-item size="mini" label-width="10px">
              <el-button size="mini" type="primary" @click="queryList">查询</el-button>
            </el-form-item>
          </el-form>
        </div>
        <!-- 主页主体表格 -->
        <split-pane split="horizontal" :default-percent="55" v-on:resize="resize">
          <template slot="paneL">
            <div class="top-type" ref="topType">
              <div class="btn-area" ref="btnArea">
                <buttonName @clickEvent="clickEventDom"></buttonName>
                <!-- 解决方案按钮组 -->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('add')" @click="addNew">新增</el-button>-->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('edit')" @click="edit">编辑</el-button>-->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('del')" @click="delDemand" >删除</el-button>-->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('copy')" @click="copyDemand" >复制</el-button>-->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('commitj')" @click="releaseDemand" >提交集团</el-button>-->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('cancel')" @click="unReleaseDemand" >取消提交集团</el-button>-->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('commitpt')" @click="commitpt" >提交平台</el-button>-->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('cancelpt')" @click="unReleasePTDemand" >取消提交平台</el-button>-->
                <!--                <el-button plain size="mini" type="primary" v-if="isAuth('commitp')" @click="genDialog" >平台汇总</el-button>-->
              </div>
              <el-table
                ref="demandTable"
                :height="typeHeight"
                class="sugarDemand"
                style="width: 100%"
                :row-style="changeRowBgColor"
                :data="demandList"
                :highlight-current-row="true"
                @selection-change="handleSelectionChange"
                @row-click="rowClick"
                border
                :header-cell-style="{ textAlign: 'center' }"
                @row-dblclick="view"
              >
                <el-table-column align="center" width="60" label="序号" :index="indexMethod" type="index" sortable></el-table-column>
                <el-table-column align="center" type="selection" width="55"></el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="需求状态" prop="statusValue" width="120">
                  <template slot-scope="scope">
                    <u @click="getSfdos(scope.row.demandCode)">{{ scope.row.statusValue }}</u>
                  </template>
                </el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="需求编号" prop="demandCode" width="160">
                  <!--                  <template slot-scope="scope">-->
                  <!--                    <u  @click="getSfdos(scope.row.demandCode)">{{scope.row.demandCode}}</u>-->
                  <!--                  </template>-->
                </el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="品牌" prop="goodBrand">
                  <template slot-scope="scope">
                    <span>{{ goodBrands[scope.row.goodBrand] }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="规格" prop="dailyOutput">
                  <template slot-scope="scope">
                    <span>{{ dailyOutputs[scope.row.dailyOutput] }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="产品大类" prop="projuctBig">
                  <template slot-scope="scope">
                    <span>{{ projuctBigs[scope.row.projuctBig] }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="品种" prop="kind" width="140">
                  <template slot-scope="scope">
                    <span>{{ kinds[scope.row.kind] }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="起始地" prop="site" width="140"></el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="目的地" prop="destination" width="140"></el-table-column>
                <!--                <el-table-column align="center" show-overflow-tooltip label="货物编码" prop="goodCode" width="140"></el-table-column>-->
                <el-table-column align="center" show-overflow-tooltip label="运输数量(吨)" prop="transportQuantity" width="140"></el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="运输方式" prop="transportMode">
                  <template slot-scope="scope">
                    <span>{{ transportModes[scope.row.transportMode] }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="结算方式" prop="settlementWay">
                  <template slot-scope="scope">
                    <span>{{ jiesuanWays[scope.row.settlementWay] }}</span>
                  </template>
                </el-table-column>
                <!--                <el-table-column align="center" show-overflow-tooltip label="特殊要求" prop="specialRequireNames" >-->
                <!--                </el-table-column>-->
                <el-table-column align="center" width="130" show-overflow-tooltip label="履约保证金" prop="performanceBond"></el-table-column>
                <!--                <el-table-column align="center" show-overflow-tooltip label="合同定金（万元）" prop="contractDeposit"></el-table-column>-->
                <el-table-column align="center" show-overflow-tooltip label="要求开始时间" width="120" prop="requiredStartTime"></el-table-column>
                <!--                <el-table-column-->
                <!--                  align="center"-->
                <!--                  show-overflow-tooltip-->
                <!--                  label="要求结束时间"-->
                <!--                  prop="requiredEndTime"-->
                <!--                ></el-table-column>-->
                <el-table-column align="center" width="130" show-overflow-tooltip label="要求完成天数" prop="requiredEndDay"></el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="提交人" prop="creator"></el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="提交时间" prop="sfdSubmitTime" width="160"></el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="驳回人" prop="sfdRefuseP"></el-table-column>
                <el-table-column align="center" width="160" show-overflow-tooltip label="驳回时间" prop="sfdRefuseT"></el-table-column>
                <el-table-column align="center" width="200" show-overflow-tooltip label="驳回意见" prop="sfdRefuseMsg"></el-table-column>
                <el-table-column
                  align="left"
                  class-name="remarkSP"
                  style="padding-right: 20px"
                  width="200"
                  show-overflow-tooltip
                  label="备注"
                  prop="remark"
                ></el-table-column>
              </el-table>
              <!-- </div> -->
              <el-pagination
                class="pagination"
                small
                background
                ref="pagination"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="Pagination.currentPage"
                :page-sizes="Pagination.pageSizeList"
                :page-size="Pagination.pageSize"
                :layout="Pagination.layout"
                :total="Pagination.total"
              ></el-pagination>
            </div>
          </template>

          <!-- 下方解决方案明细表格 -->
          <template slot="paneR">
            <div class="codeNumberCode" style="background-color: #fff;">线路信息</div>
            <div class="bottom-code" ref="bottomCode" style="background-color: #fff;">
              <el-table :data="mainBotTableData" border :height="detlHeight" :header-cell-style="{ textAlign: 'center' }" highlight-current-row>
                <el-table-column type="index" align="center" width="60" label="序号"></el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="起始地" prop="dliSProvinceName,dliSCtiyeName,dliSCityName,site">
                  <template slot-scope="scope"
                    >{{ scope.row.dliSProvinceName }} {{ scope.row.dliSCtiyeName }} {{ scope.row.dliSCityName }} {{ scope.row.site }}</template
                  >
                </el-table-column>
                <el-table-column align="center" show-overflow-tooltip label="目的地" prop="dliDProvinceName,dliDCtiyeName,dliDCityName,destination">
                  <template slot-scope="scope"
                    >{{ scope.row.dliDProvinceName }} {{ scope.row.dliDCtiyeName }} {{ scope.row.dliDCityName }} {{ scope.row.destination }}</template
                  >
                </el-table-column>
                <!--                    <el-table-column align="left" show-overflow-tooltip label="每日可完成的运量" prop="dailyShippingVolume"></el-table-column>-->

                <!--                <el-table-column align="left" show-overflow-tooltip label="备注" prop="lineRemark"></el-table-column>-->
              </el-table>
            </div>
          </template>
        </split-pane>
      </div>
    </template>

    <el-dialog
      width="1200px"
      top="5vh"
      v-dialogDrag
      v-el-drag-dialog
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-if="showDialog"
      :visible.sync="showDialog"
      :title="operate"
    >
      <v-dialog
        :dialogmode="operate"
        :disabled="!isEditMode"
        :disabledr="!isEditMode2"
        @closeEdit="closeEdit"
        @save="saveFltInfo"
        @dialogSave="dialogSave"
        :flt_info="currentFltInfo"
        :demand_line_infos="demandLineInfosObject"
      ></v-dialog>
    </el-dialog>

    <el-dialog
      v-el-drag-dialog
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-if="showSeeDialog"
      :visible.sync="showSeeDialog"
      :title="operate"
    >
      <s-dialog :disabled="!isEditMode1" @close="closeEdit" @save="saveFltInfo" :flt_info="currentFltInfo" :userdata="usersData"></s-dialog>
    </el-dialog>

    <!-- 生成标书dilog -->
    <biddingDialog :info="dialogText"></biddingDialog>
    <!-- 需求操作dilog -->
    <el-dialog
      :title="name"
      width="80%"
      :visible.sync="openDialogB"
      v-if="openDialogB"
      v-el-drag-dialog
      close-on-press-escape="false"
      :before-close="close"
      :close-on-click-modal="false"
    >
      <div class="botTable">
        <div class="botTableTitle">需求操作</div>
        <div class="botTableBox">
          <el-table :data="botTableData" border :height="detlHeight" :header-cell-style="{ textAlign: 'center' }" highlight-current-row>
            <el-table-column type="index" align="center" label=" " width="50"></el-table-column>
            <el-table-column prop="sfdoType" label="操作类型" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="sfdoStatus" label="操作状态" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="sfdoSdfDemandCode" label="需求编号" show-overflow-tooltip sortable></el-table-column>
            <el-table-column prop="sfdoCreator" label="操作人" show-overflow-tooltip></el-table-column>
            <el-table-column prop="sfdoCreatetime" label="操作时间" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="sfdoMessage" label="驳回意见" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="sfdoRemark" label="备注" show-overflow-tooltip></el-table-column>
          </el-table>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import VDialog from './dialog'
import SDialog from './seedialog'
import biddingDialog from '@/views/Summary/twoSummary/threeSummary/dialog'
import resizeMixin from '@/mixins/resize'
import isAuth from '@/mixins/buttonAuth'
import paginationMixin from '@/mixins/pagination'

import {
  addBid,
  bidDropDown,
  checkAllSugarDmand,
  delsysdepartment,
  genBidCode,
  getRefCodesByType,
  quertLineInfo,
  queryDemand,
  queryDemandLine,
  updateBid,
  genBidName,
  getWillBillStatus,
  updateBidBatch
} from '@/request/api'
import {
  delDmandService,
  generateRequirementNumberService,
  queryAllSfdoService,
  releaseDmandService,
  submitDmandService,
  unReleaseDmandService
} from '@/request/SugarFactory/sugarFactoryDmand/sugarDmand'
import { getBrandListDropDownSer, getNormListDropDownSer, getProjectBigDropDownSer, getVarietiesDefaultDropDownSer } from '@/request/dropDown'
import store from '@/store'
import scrollChange from '@/utils/onscroll'
import buttonName from '@/components/buttonName/button-name.vue'

export default {
  name: 'router.tertiarySugarFactory',
  mixins: [resizeMixin, paginationMixin, isAuth],
  data() {
    return {
      flt: {
        site: '',
        destination: '',
        demandCode: '',
        // status: 'NFB',
        status: '',
        submitStartTime: '',
        submitEndTime: ''
      },

      selectRow: [], //选中所有的数据
      selectAllArray: [], //选中所有的数据
      selNoApproveArray: [], //未提交的数据
      selApproveArray: [], //已提交的数据
      selApproveJTArray: [], //已提交集团的数据
      selApprovePTArray: [], //已提交平台的数据

      transportModeList: [], //运输类型
      demandList: [],
      demandStatus: [],
      kinds: [], //品种下拉数据
      kindsDF: '', //品种下拉默认值
      goodBrands: [], //货物品牌
      goodBrandsDF: '', //货物品牌默认值
      dailyOutputs: [], //货物规格
      dailyOutputsDF: '', //货物规格默认值
      projuctBigs: [], //产品大类
      projuctBigsDF: '', //产品大类默认值
      specialRequirements: [], // 特殊要求
      transportModes: {
        RO: '公路运输',
        DS: '多式联运'
      },
      jiesuanWays: {
        现结: '现结',
        账期支付: '账期支付'
      },
      // specialRequirements: {
      //   Y: '回收吊带',
      //   N: '不回收吊带',
      //   'Y\\,N': '回收吊带,不回收吊带',
      // },
      // 查看用户
      usersData: [],
      // 派车中心下拉
      alldptList: [],

      bidQuotations: [], //竞价方式下拉

      isEditMode: true,
      isEditMode2: true,
      operate: '',
      showDialog: false,
      openDialogB: false,
      showSeeDialog: false,

      activeNames: ['1'], // 控制主页下方 需求明细表格的展示
      mainBotTableData: [], // 主页下方 需求明细表格数据
      detlHeight: -1, // 主页下方 表格高度
      typeHeight: -1, //主页上方 表格高度
      refCodesDatas: [], //运输方式代码
      botTableData: [], //需求操作数据
      sfdoStatusS: [], //需求状态数据

      currentRow: {},
      currentFltInfo: {},
      demandLineInfosObject: {},

      roleStatus: [],
      rules: {
        dptCode: [{ min: 0, max: 20, message: '输入至多20个字符', trigger: 'blur' }],
        dptName: [{ min: 0, max: 37, message: '至多输入37个字符', trigger: 'blur' }]
      },

      bidTypeDataList: [],
      bidStatusDataList: [],
      queryParam: {
        code: '', // 标的编号
        status: '' // 标的状态
      },
      tableDomain: {
        mTable: {
          data: [],
          loading: false,
          currentData: {},
          pageInfo: {
            pageIndex: 1,
            pageSize: 10,
            total: 0
          }
        },
        sTable: {
          data: [],
          loading: false
        },
        dTable: {
          data: [],
          loading: false,
          queryParam: {
            code: '',
            site: '',
            destination: ''
          },
          selectChangeData: [],
          selectBoxShow: true,
          pageInfo: {
            pageIndex: 1,
            pageSize: 10,
            total: 0
          }
        }
      },
      dialogFrom: {
        diable: {
          allDisable: false
        },
        data: {
          bidAmount: 0,
          bidCode: '',
          bidName: '',
          bidQuotations: '',
          bidRange: '',
          bidRemark: '',
          bidPlatformTogether: 'N',
          bidOfferStart: '',
          bidOfferEnd: ''
        },
        rules: {
          bidCode: [{ required: true, message: '输入标的编号', trigger: 'blur' }],
          bidType: [{ required: true, message: '请选择标的类型', trigger: 'change' }],
          bidName: [{ required: true, message: '请输入标的名称', trigger: 'blur' }],
          bidPlatformTogether: [{ required: true, message: '请选择是否平台合作', trigger: 'blur' }]
          // bidAmount: [
          //   { required: true, message: '请输入数量', trigger: 'change' }
          // ]
        }
      },
      dialogText: {
        title: '',
        show: false,
        button: {
          t: '',
          f: ''
        },
        selectBoxShow: false,
        qeuryButtonShow: false,
        paginationShow: false,
        refuseShow: true,
        historyShow: false,
        submitTimeShow: false,
        sugarModeListShow: false,
        sugarModeListName: '',
        currentData: {},
        topFormShow: true,
        selectData: [], // 当前表格勾选的需求
        source: 1 // 表明组件的来源
      },
      tranDialogInfo: {
        title: '',
        show: false,
        table: {
          data: []
        }
      },
      genName: {
        dptName: '',
        typeName: '',
        code: ''
      }
    }
  },

  methods: {
    clickEventDom(item) {
      console.log(item)
      if (item.mdlCode === 'add') {
        this.addNew()
      } else if (item.mdlCode === 'edit') {
        this.edit()
      } else if (item.mdlCode === 'del') {
        this.delDemand()
      } else if (item.mdlCode === 'copy') {
        this.copyDemand()
      } else if (item.mdlCode === 'commitj') {
        this.releaseDemand()
      } else if (item.mdlCode === 'cancel') {
        this.unReleaseDemand()
      } else if (item.mdlCode === 'commitpt') {
        this.commitpt()
      } else if (item.mdlCode === 'cancelpt') {
        this.unReleasePTDemand()
      } else if (item.mdlCode === 'commitp') {
        this.genDialog()
      }
    },

    dialogSave(info) {
      this.showDialog = info
      this.refreshList()
    },
    // 重写的获取列表数据的方法
    getList(currentPage, pageSize, updateTotal) {
      checkAllSugarDmand({
        site: this.flt.site,
        destination: this.flt.destination,
        demandCode: this.flt.demandCode,
        status: this.flt.status,
        PageIndex: this.Pagination.currentPage,
        PageSize: this.Pagination.pageSize,
        submitStartTime: this.flt.submitStartTime,
        submitEndTime: this.flt.submitEndTime
      }).then(res => {
        this.demandList = res.data
        updateTotal(Number(res.total))
        // this.demandList.forEach(item => {
        //   item.specialRequireNames = ''
        //   item.specialRequires.forEach(val => {
        //     item.specialRequireNames += this.specialRequirements[val] + ','
        //   })
        // })
      })
      this.currentRow = {}
    },
    //点击运单号弹出运单动态信息
    getSfdos() {
      setTimeout(() => {
        queryAllSfdoService({
          sfdoSdfDemandCode: this.currentRow.demandCode
        }).then(res => {
          // index" align="cen
          // sfdoType" label="
          // sfdoStatus" label
          // sfdoSdfDemandCode
          // sfdoCreator" labe
          // sfdoCreatetime" l
          // sfdoRemark" label
          this.botTableData = res.data.map(item => {
            return {
              sfdoType: item.sfdoType,
              sfdoStatus: this.sfdoStatusS[item.sfdoStatus],
              sfdoSdfDemandCode: item.sfdoSdfDemandCode,
              sfdoCreator: item.sfdoCreator,
              sfdoCreatetime: item.sfdoCreatetime,
              sfdoRemark: item.sfdoRemark,
              sfdoMessage: item.sfdoMessage
            }
          })
        }, 300)
      })
      this.openDialogB = true
    },
    queryList() {
      this.refreshList()
    },

    //被平台修改过的需求显示黄色
    changeRowBgColor({ row, rowIndex }) {
      let styleJson = {}
      // 多选高亮选中行
      if (this.selectRow.includes(rowIndex)) {
        styleJson = { 'background-color': 'rgba(87, 134, 238, 1)' }
      }
      if (row.isEdit === 'Y') {
        styleJson = { 'background-color': 'yellow' }
      }
      return styleJson
    },
    // 获取当前选中行
    handleSelectionChange(val) {
      if (val.length) {
        if (!Object.keys(this.currentRow).length) {
          this.currentRow = val[0]
        }
      }
      this.selectAllArray = []
      this.selNoApproveArray = []
      this.selApproveArray = []
      this.selApproveJTArray = []
      this.selApprovePTArray = []
      if (val.length > 0) {
        for (var i = 0; i < val.length; i++) {
          this.selectAllArray.push(val[i])
          //判读是否为未提交（NFB：未提交）
          if (val[i].status == 'NFB' || val[i].status == 'BOH') {
            this.selNoApproveArray.push(val[i])
          } else {
            this.selApproveArray.push(val[i])
            if (val[i].status == 'YFB') {
              this.selApproveJTArray.push(val[i])
            } else {
              this.selApprovePTArray.push(val[i])
            }
          }
        }
      }
    },

    rowClick(row) {
      this.$refs['demandTable'].toggleRowSelection(row)
      this.currentRow = row
      this.getDemandDetailData()
      // setTimeout(() => {
      //   this.getDemandDetailData()
      // }, 300)
    },
    getDemandDetailData() {
      quertLineInfo(this.currentRow).then(res => {
        this.mainBotTableData = res.data
        for (let i = 0; i < res.data.length; i++) {
          const source = this.currentFltInfo.demandLineInfos[i]
          const data = res.data[i]
          source.startSelect = [data.dliSProvince, data.dliSCity, data.dliSArea]
          source.endSelect = [data.dliDProvince, data.dliDCity, data.dliDArea]
        }
      })
    },

    addNew() {
      console.log(111111111111111)
      this.operate = this.DIALOG_MODE.ADD
      this.isEditMode = true
      this.isEditMode2 = true
      this.currentFltInfo = {
        demandLineInfos: [
          {
            site: '',
            destination: '',
            dailyShippingVolume: '',
            // bidPrice: '',
            status: '1'
          }
        ],
        demandCode: '', // 需求编号
        kind: this.kindsDF, // 品种
        goodCode: '', //货物编码
        transportType: 'ZJZY', // 运输类型
        transportMode: 'RO', // 运输方式
        dailyOutput: this.dailyOutputsDF, // 日产量（后改为规格）
        transportQuantity: '', // 榨季期间运输数量
        settlementWay: '现结',
        specialRequire: ['Y'], //特殊要求
        projuctBig: this.projuctBigsDF, //产品大类
        contractDeposit: '', // 合同定金
        goodBrand: this.goodBrandsDF, // 货物品牌
        requiredStartTime: new Date(), // 要求开始时间
        requiredEndTime: '', // 要求完成时间
        remark: '', // 备注
        status: '1'
      }
      generateRequirementNumberService().then(res => {
        this.currentFltInfo.demandCode = res.data
      })
      this.showDialog = true
    },
    edit() {
      if (this.currentRow.status == 'YFB') {
        this.$alert('已提交集团的需求不允许编辑！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (this.currentRow.status == 'JTSH') {
        this.$alert('集团已审核的需求不允许编辑！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (this.currentRow.status == 'JTHZ') {
        this.$alert('集团汇总的需求不允许编辑！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (this.currentRow.status == 'YTJ') {
        this.$alert('已提交平台不允许编辑！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (this.currentRow.status == 'PTHZ') {
        this.$alert('平台汇总的需求不允许编辑！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (Object.keys(this.currentRow).length == 0) {
        this.$alert('请选择需要编辑的需求！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.operate = this.DIALOG_MODE.EDIT
      this.isEditMode = true
      this.isEditMode2 = false
      this.currentFltInfo = Object.assign({}, this.currentRow)
      quertLineInfo({ sugarId: this.currentRow.sugarId }).then(res => {
        res.data.forEach(item => {
          item.status = '1'
        })
        this.currentFltInfo.demandLineInfos = res.data
        for (let i = 0; i < res.data.length; i++) {
          const source = this.currentFltInfo.demandLineInfos[i]
          const data = res.data[i]
          source.startSelect = [data.dliSProvince, data.dliSCity, data.dliSArea]
          source.endSelect = [data.dliDProvince, data.dliDCity, data.dliDArea]
        }
      })
      this.showDialog = true
    },
    copyDemand() {
      if (Object.keys(this.currentRow).length == 0) {
        this.$alert('请选择需要复制的需求！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.operate = '复制需求'
      this.isEditMode = true
      this.isEditMode2 = false
      this.currentFltInfo = Object.assign({}, this.currentRow)
      console.log(this.currentRow, ' this.currentRow')
      this.currentFltInfo.transportQuantity = ''
      quertLineInfo({ sugarId: this.currentRow.sugarId }).then(res => {
        res.data.forEach(item => {
          item.status = '1'
        })
        this.demandLineInfosObject = res.data[0]
        this.currentFltInfo.demandLineInfos = res.data
        for (let i = 0; i < res.data.length; i++) {
          const source = this.currentFltInfo.demandLineInfos[i]
          const data = res.data[i]
          source.startSelect = [data.dliSProvince, data.dliSCity, data.dliSArea]
          source.endSelect = [data.dliDProvince, data.dliDCity, data.dliDArea]
        }
        this.currentFltInfo.requiredStartTime = new Date()
        let day = this.currentRow.requiredEndDay * 24 * 3600 * 1000
        this.currentFltInfo.requiredEndTime = new Date(Date.parse(this.currentFltInfo.requiredStartTime) + day)
      })
      generateRequirementNumberService().then(res => {
        this.currentFltInfo.demandCode = res.data
      })
      this.showDialog = true
    },
    delDemand() {
      let t = this
      if (t.selectAllArray.length != 0) {
        if (t.selApproveArray != 0) {
          let FBstatus = []
          FBstatus = t.selApproveArray.map(s => s.status)
          if (FBstatus.includes('YFB')) {
            t.$message.error('已提交集团的需求不可删除')
          } else if (FBstatus.includes('JTSH')) {
            t.$message.error('集团已审核的需求不可删除')
          } else if (FBstatus.includes('JTHZ')) {
            t.$message.error('集团汇总的需求不可删除')
          } else if (FBstatus.includes('YTJ')) {
            t.$message.error('已提交平台的需求不可删除')
          } else if (FBstatus.includes('PTHZ')) {
            t.$message.error('平台汇总的需求不可删除')
          }
          return
        }

        this.$confirm('您确认要将选定的' + t.selNoApproveArray.length + '条需求删除吗?', '提示', {
          closeOnClickModal: false
        }).then(() => {
          let li = t.selNoApproveArray
          li.forEach(item => {
            delDmandService({
              sugarId: item.sugarId
            }).then(() => {
              this.refreshList()
            })
          })
          this.$message({
            message: '批量删除需求成功！',
            type: 'success',
            showClose: true
          })
        })
      } else {
        if (this.currentRow.status == 'YFB') {
          this.$alert('已提交集团的需求不允许删除！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        if (this.currentRow.status == 'JTSH') {
          this.$alert('集团已审核的需求不允许删除！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        if (this.currentRow.status == 'JTHZ') {
          this.$alert('集团汇总的需求不允许删除！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        if (this.currentRow.status == 'YTJ') {
          this.$alert('已提交平台的需求不允许删除！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        if (this.currentRow.status == 'PTHZ') {
          this.$alert('平台汇总的需求不允许删除！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        if (Object.keys(this.currentRow).length == 0) {
          this.$alert('请选择需要删除的需求！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        this.$confirm('您确认要删除选定的需求吗?', '提示', {
          closeOnClickModal: false
        }).then(() => {
          let leta = {}
          leta['sugarId'] = this.currentRow.sugarId
          leta['version'] = this.currentRow.version
          delDmandService(leta).then(() => {
            this.$message({
              message: '删除成功！',
              type: 'success',
              showClose: true
            })
            this.refreshList()
          })
        })
      }
    },
    releaseDemand() {
      let t = this
      if (t.selectAllArray.length != 0) {
        if (t.selApproveArray != 0) {
          t.$message.error('不能重复提交')
          return
        }
        this.$confirm('您确认要将所选定的' + t.selNoApproveArray.length + '条需求提交集团吗?', '提示', {
          closeOnClickModal: false
        }).then(() => {
          let li = t.selNoApproveArray
          li.forEach(item => {
            releaseDmandService({
              sugarId: item.sugarId,
              status: 'YFB'
            }).then(() => {
              this.refreshList()
            })
          })
          this.$message({
            message: '提交集团成功！',
            type: 'success',
            showClose: true
          })
        })
      } else {
        t.$message.error('请勾选至少一条需求')
      }
      //
      //
      // if (this.currentRow.status == 'YFB') {
      //   this.$alert('该需求已提交集团，不可重复操作！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // if (this.currentRow.status == 'YTJ') {
      //   this.$alert('该需求已提交平台，不允许提交集团！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // if (Object.keys(this.currentRow).length == 0) {
      //   this.$alert('请选择需要提交集团的需求！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // this.$confirm('您确定要将此需求提交给集团吗?', '提示', {
      //   closeOnClickModal: false
      // }).then(() => {
      //   let leta = {}
      //   leta['sugarId'] = this.currentRow.sugarId
      //   leta['version'] = this.currentRow.version
      //   releaseDmandService(leta).then(() => {
      //     this.$message({
      //       message: '提交集团成功！',
      //       type: 'success',
      //       showClose: true
      //     })
      //     this.refreshList()
      //   })
      // })
    },
    commitpt() {
      let t = this
      if (t.selectAllArray.length != 0) {
        if (t.selApproveArray != 0) {
          t.$message.error('不能重复提交')
          return
        }
        this.$confirm('您确认要将所选定的' + t.selNoApproveArray.length + '条需求提交平台吗?', '提示', {
          closeOnClickModal: false
        }).then(() => {
          let li = t.selNoApproveArray
          li.forEach(item => {
            releaseDmandService({
              sugarId: item.sugarId,
              status: 'TJPT'
            }).then(() => {
              this.refreshList()
            })
          })
          this.$message({
            message: '提交平台成功！',
            type: 'success',
            showClose: true
          })
        })
      } else {
        t.$message.error('请勾选至少一条需求')
      }
      //
      //
      // if (this.currentRow.status == 'YFB') {
      //   this.$alert('该需求已提交集团，不可重复操作！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // if (this.currentRow.status == 'YTJ') {
      //   this.$alert('该需求已提交平台，不允许提交集团！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // if (Object.keys(this.currentRow).length == 0) {
      //   this.$alert('请选择需要提交集团的需求！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // this.$confirm('您确定要将此需求提交给集团吗?', '提示', {
      //   closeOnClickModal: false
      // }).then(() => {
      //   let leta = {}
      //   leta['sugarId'] = this.currentRow.sugarId
      //   leta['version'] = this.currentRow.version
      //   releaseDmandService(leta).then(() => {
      //     this.$message({
      //       message: '提交集团成功！',
      //       type: 'success',
      //       showClose: true
      //     })
      //     this.refreshList()
      //   })
      // })
    },
    mci(i) {
      this.tableDomain.mTable.pageInfo.pageIndex = i
      this.initMTable()
    },
    mcs(i) {
      this.tableDomain.mTable.pageInfo.pageSize = i
      this.initMTable()
    },
    dci(i) {
      this.tableDomain.dTable.pageInfo.pageIndex = i
      this.dTableDataList()
    },
    dcs(i) {
      this.tableDomain.dTable.pageInfo.pageSize = i
      this.dTableDataList()
    },
    // dialog 查看线路详细信息
    showTransportMethod(val) {
      this.tableDomain.dTable.clickData = val
      this.initTranMethodTable()
      this.tranDialogInfo.title = '线路详情'
      this.tranDialogInfo.show = true
    },
    submitDemand() {
      if (this.currentRow.status == 'YTJ') {
        this.$alert('该需求已提交平台，不可重复操作！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (Object.keys(this.currentRow).length == 0) {
        this.$alert('请选择需要提交平台的需求！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.$confirm('您确认要提交平台选定的需求吗?', '提示', {
        closeOnClickModal: false
      }).then(() => {
        let leta = {}
        leta['sugarId'] = this.currentRow.sugarId
        leta['version'] = this.currentRow.version
        submitDmandService(leta).then(() => {
          this.$message({
            message: '提交平台成功！',
            type: 'success',
            showClose: true
          })
          this.refreshList()
        })
      })
    },
    unReleaseDemand() {
      // if (this.currentRow.status != 'YFB') {
      //   this.$alert('该需求未提交集团！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // if (Object.keys(this.currentRow).length == 0) {
      //   this.$alert('请选择需要取消提交集团的需求！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }

      let t = this
      if (t.selectAllArray.length != 0) {
        if (t.selNoApproveArray != 0) {
          let Nostatus = []
          Nostatus = t.selNoApproveArray.map(s => s.status)
          if (Nostatus.includes('NFB')) {
            t.$message.error('未提交集团的需求无法取消')
          } else {
            t.$message.error('驳回的需求无法取消')
          }
          return
        }
        if (t.selApprovePTArray != 0) {
          let PTstatus = []
          PTstatus = t.selApprovePTArray.map(s => s.status)
          if (PTstatus.includes('YTJ')) {
            t.$message.error('已提交平台的需求无法取消提交集团')
          } else if (PTstatus.includes('PTHZ')) {
            t.$message.error('平台汇总的需求无法取消')
          } else if (PTstatus.includes('JTHZ')) {
            t.$message.error('集团汇总的需求无法取消')
          } else if (PTstatus.includes('JTSH')) {
            t.$message.error('集团已审核的需求无法取消')
          }
          // t.$message.error('未提交集团的无法取消')
          return
        }

        this.$confirm('您确认要将选定的' + t.selApproveJTArray.length + '条需求取消提交集团吗?', '提示', {
          closeOnClickModal: false
        }).then(() => {
          let li = t.selApproveJTArray
          li.forEach(item => {
            console.log(item, 'item')
            unReleaseDmandService({
              sugarId: item.sugarId
            }).then(() => {
              this.refreshList()
            })
          })
          this.$message({
            message: '取消提交集团成功！',
            type: 'success',
            showClose: true
          })
        })
      } else {
        t.$message.error('请勾选至少一条需求')
      }

      // this.$confirm('您确认要取消提交集团选定的需求吗?', '提示', {
      //   closeOnClickModal: false
      // }).then(() => {
      //   let leta = {}
      //   leta['sugarId'] = this.currentRow.sugarId
      //   leta['version'] = this.currentRow.version
      //   unReleaseDmandService(leta).then(() => {
      //     this.$message({
      //       message: '取消提交集团成功！',
      //       type: 'success',
      //       showClose: true
      //     })
      //     this.refreshList()
      //   })
      // })
    },
    unReleasePTDemand() {
      // if (this.currentRow.status != 'YFB') {
      //   this.$alert('该需求未提交集团！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // if (Object.keys(this.currentRow).length == 0) {
      //   this.$alert('请选择需要取消提交集团的需求！', '提示', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }

      let t = this
      if (t.selectAllArray.length != 0) {
        console.log(111111)
        if (t.selNoApproveArray != 0) {
          let Nostatus = []
          Nostatus = t.selNoApproveArray.map(s => s.status)
          if (Nostatus.includes('NFB')) {
            t.$message.error('未提交平台的需求无法取消')
          } else {
            t.$message.error('驳回的需求无法取消')
          }
          return
        }
        console.log(2222222)
        if (t.selApprovePTArray != 0) {
          console.log(333333333)
          let PTstatus = []
          let allStatus = []
          PTstatus = t.selApprovePTArray.map(s => s.status)
          // allStatus = t.selApproveArray.map(m => m.status)
          // if (allStatus.includes('YFB')) {
          //   t.$message.error('已提交集团的需求无法取消提交平台')
          // }
          console.log(44444444)
          if (PTstatus.includes('PTHZ')) {
            t.$message.error('平台汇总的需求无法取消')
          } else if (PTstatus.includes('JTHZ')) {
            t.$message.error('集团汇总的需求无法取消')
          } else if (PTstatus.includes('JTSH')) {
            t.$message.error('集团已审核的需求无法取消')
          } else if (!PTstatus.includes('TJPT')) {
            return
          }
        }
        console.log(66666666666)

        this.$confirm('您确认要将选定的' + t.selApprovePTArray.length + '条需求取消提交平台吗?', '提示', {
          closeOnClickModal: false
        }).then(() => {
          let li = t.selApprovePTArray
          li.forEach(item => {
            console.log(item, 'item')
            unReleaseDmandService({
              sugarId: item.sugarId
            }).then(() => {
              this.refreshList()
            })
          })
          this.$message({
            message: '取消提交平台成功！',
            type: 'success',
            showClose: true
          })
        })
      } else {
        t.$message.error('请勾选至少一条需求')
      }

      // this.$confirm('您确认要取消提交集团选定的需求吗?', '提示', {
      //   closeOnClickModal: false
      // }).then(() => {
      //   let leta = {}
      //   leta['sugarId'] = this.currentRow.sugarId
      //   leta['version'] = this.currentRow.version
      //   unReleaseDmandService(leta).then(() => {
      //     this.$message({
      //       message: '取消提交集团成功！',
      //       type: 'success',
      //       showClose: true
      //     })
      //     this.refreshList()
      //   })
      // })
    },
    unReleasePT() {
      if (this.currentRow.status != 'NTJ') {
        this.$alert('该需求未提交平台！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (Object.keys(this.currentRow).length == 0) {
        this.$alert('请选择需要取消提交平台的需求！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.$confirm('您确认要取消提交平台选定的需求吗?', '提示', {
        closeOnClickModal: false
      }).then(() => {
        let leta = {}
        leta['sugarId'] = this.currentRow.sugarId
        leta['version'] = this.currentRow.version
        unReleaseDmandService(leta).then(() => {
          this.$message({
            message: '取消提交平台成功！',
            type: 'success',
            showClose: true
          })
          this.refreshList()
        })
      })
    },
    view(row) {
      this.operate = this.DIALOG_MODE.VIEW
      this.isEditMode = false
      this.isEditMode2 = false
      this.currentFltInfo = Object.assign({}, row)
      quertLineInfo({ sugarId: this.currentRow.sugarId }).then(res => {
        res.data.forEach(item => {
          item.status = '1'
        })
        this.currentFltInfo.demandLineInfos = res.data
        for (let i = 0; i < res.data.length; i++) {
          const source = this.currentFltInfo.demandLineInfos[i]
          const data = res.data[i]
          source.startSelect = [data.dliSProvince, data.dliSCity, data.dliSArea]
          source.endSelect = [data.dliDProvince, data.dliDCity, data.dliDArea]
        }
      })
      this.showDialog = true
    },
    // 查看用户dialog
    see(row) {
      this.operate = this.DIALOG_MODE.SEE
      this.isEditMode1 = true
      this.showSeeDialog = true
      this.showDialog = false
      checkusersList({ dptId: row.dptId }).then(res => {
        this.usersData = res.data
      })
    },
    closeEdit() {
      this.showDialog = false
      // this.showSeeDialog = false
      this.refreshList()
    },
    saveFltInfo(info) {
      switch (this.operate) {
      case this.DIALOG_MODE.ADD:
        var itemType = Object.assign({ dptFltId: this.currentRow.dptFltId }, info)
        checkusersList(itemType).then(() => {
          this.$message({
            message: '新增成功！',
            type: 'success',
            showClose: true
          })
          this.showDialog = false
          this.refreshList()
        })
        break
      case this.DIALOG_MODE.EDIT:
        editsysdepartment(info).then(() => {
          this.$message({
            message: '编辑成功！',
            type: 'success',
            showClose: true
          })
          this.showDialog = false
          this.refreshList()
        })
        break
      default:
        break
      }
    },

    dialogInputNumberEndChange(val) {
      if (val < this.dialogFrom.data.bidOfferStart) {
        this.dialogFrom.data.bidOfferStart = val
      }
    },
    dialogInputNumberStartChange(val) {
      if (val > this.dialogFrom.data.bidOfferEnd) {
        this.dialogFrom.data.bidOfferEnd = val
      }
    },
    // del() {
    //   if (Object.keys(this.currentRow).length == 0) {
    //     this.$alert('请选择需要删除的数据', '提示', {
    //       confirmButtonText: '确定'
    //     })
    //     return
    //   }
    //   this.$confirm('您确认要删除选定的数据吗?', '提示', {
    //     closeOnClickModal: false
    //   }).then(() => {
    //     let leta = {}
    //     leta['dptId'] = this.currentRow.dptId
    //     leta['version'] = this.currentRow.version
    //     delsysdepartment(leta).then(() => {
    //       this.$message({
    //         message: '删除成功！',
    //         type: 'success',
    //         showClose: true
    //       })
    //       this.refreshList()
    //     })
    //   })
    // },
    clearState() {
      this.currentRow = {}
      this.currentFltInfo = {}
    },
    //查看用户信息
    getUserInfo() {},
    // 监听主页下方表格的展示
    handleChange(val) {
      if (val.length == 0) {
        this.mainTopHeight = 660
      } else {
        this.mainTopHeight = 400
      }
    },
    // 标的类型
    initBidType() {
      let t = this
      bidDropDown({
        name: '标的类型'
      }).then(res => {
        if (res.success == 1) {
          t.bidTypeDataList = res.data
        }
      })
    },
    bidTypeChange(val) {
      this.genName.typeName = val
      this.dialogFrom.data.bidName = (this.genName.dptName ? this.genName.dptName : '') + val + this.genName.code
    },
    initBidStatus() {
      let t = this
      bidDropDown({
        name: '标书状态'
      }).then(res => {
        if (res.success == 1) {
          t.bidStatusDataList = res.data
        }
      })
    },

    initBidQuotations() {
      let t = this
      bidDropDown({
        name: '标书竞价方式'
      }).then(res => {
        if (res.success == 1) {
          t.bidQuotations = res.data
        }
      })
    },
    // 生成标书dialog
    genDialog() {
      if (this.selectAllArray.length) {
        for (let item of this.selectAllArray) {
          if (item.statusValue !== '未提交') {
            this.$message.error({
              showClose: false,
              message: '请选择未提交的数据'
            })
            return
          }
        }
      }
      this.dialogText.title = '提交平台'
      this.dialogText.button.t = '确 定'
      this.dialogText.button.f = '取 消'
      this.dialogText.selectBoxShow = true
      this.dialogText.paginationShow = true
      this.dialogText.qeuryButtonShow = true
      this.dialogText.historyShow = false
      this.dialogText.refuseShow = false
      this.dialogText.submitTimeShow = false
      this.dialogText.sugarModeListShow = false
      this.dialogText.topFormShow = true
      this.dialogText.show = true
      this.dialogText.selectData = this.selectAllArray
      this.dialogText.sugarModeListName = '糖厂：'
    },
    // 初始化dialog表格
    dTableDataList() {
      let t = this
      let data = {
        code: t.tableDomain.dTable.queryParam.code,
        site: t.tableDomain.dTable.queryParam.site,
        destination: t.tableDomain.dTable.queryParam.destination,
        pageIndex: t.tableDomain.dTable.pageInfo.pageIndex,
        pageSize: t.tableDomain.dTable.pageInfo.pageSize,
        transportMode: t.tableDomain.dTable.queryParam.transportMode,
        source: 0,
        status: 'NFB'
      }
      if (t.dialogText.title == '编辑') {
        data.checked = '1'
        data.bidId = t.tableDomain.mTable.currentData.bidId
      }
      queryDemand(data).then(res => {
        if (res.success == 1) {
          t.tableDomain.dTable.selectChangeData = []
          t.tableDomain.dTable.data = res.data
          t.tableDomain.dTable.pageInfo.total = res.total
          if (t.dialogText.title == '编辑') {
            setTimeout(() => {
              for (let i in t.$refs.dTableRef.data) {
                if (t.$refs.dTableRef.data[i].checked == 'Y') {
                  t.$refs['dTableRef'].toggleRowSelection(t.$refs.dTableRef.data[i], true)
                }
              }
            }, 200)
          }
        }
      })
    },
    // dialog 确定
    dilogT(from) {
      let t = this
      if (t.dialogText.title == '提交平台') {
        t.$refs[from].validate(valid => {
          if (valid) {
            if (t.tableDomain.dTable.selectChangeData.length == 0) {
              t.$message.error('请选择需求')
              return
            }
            // t.tableDomain.dTable.selectChangeData.forEach(demandItem => {
            //   submitDmandService({ sugarId: demandItem.sugarId }).then(() => {})
            // })
            let f = t.dialogFrom.data
            f.bidStatus = 'TJPT'
            // 表明是从糖厂 货主直接提交的
            f.checked = 1
            addBid({
              from: f,
              demandDTOS: t.tableDomain.dTable.selectChangeData
            }).then(res => {
              if (res.success == 1) {
                t.dialogText.show = false
                t.$message.success('提交成功')
                t.dilogF()
              }
            })
            return
          }
          t.$message.error('请输入必填项')
        })
        return
      } else if (t.dialogText.title == '提交') {
        let d = t.tableDomain.mTable.currentData
        d.bidStatus = 'TJPT'
        Object.assign(d, t.dialogFrom.data)
        updateBid(d).then(res => {
          if (res.success == 1) {
            t.dialogText.show = false
            t.$message.success('提交成功')
            t.dilogF()
          }
        })
      } else if (t.dialogText.title == '编辑') {
        if (this.tableDomain.dTable.selectChangeData.length == 0) {
          this.$message.error('请至少选择一条需求')
          return
        }
        let p = {}
        Object.assign(p, t.dialogFrom.data)
        p.demandDTOS = t.tableDomain.dTable.selectChangeData
        p.bidStatus = ''
        updateBid(p).then(res => {
          if (res.success == 1) {
            t.$message.success('修改成功')
            t.dialogText.show = false
            t.dilogF()
          }
        })
      } else {
        t.$message.error('无效的选项')
        t.dialogText.show = false
        t.dilogF()
      }
    },
    // z
    dilogF() {
      let t = this
      t.dialogText.show = false
      t.dialogFrom.data.bidAmount = 0
      t.$refs['dialogFrom'].resetFields()
      t.tableDomain.dTable.selectChangeData = []
      t.tableDomain.dTable.data = []
      t.tableDomain.dTable.queryParam = {}
      t.tableDomain.mTable.currentData = {}
      t.queryParam = {}
      t.dialogFrom.diable.allDisable = false
      this.searchList()
      t.initMTable()
    },
    dSelect(val) {
      this.tableDomain.dTable.selectChangeData = val
      this.dialogFrom.data.bidAmount = 0
      if (val.length != 0) {
        let sum = 0
        val.forEach(e => {
          sum = sum + parseInt(e.transportQuantity)
        })
        this.dialogFrom.data.bidAmount = sum
      }
    },
    initTranMethodTable() {
      queryDemandLine({
        sugarId: this.tableDomain.dTable.clickData.sugarId
      }).then(res => {
        if (res.success == 1) {
          this.tranDialogInfo.table.data = res.data
        }
      })
    },
    //关闭需求操作对话框
    close() {
      this.openDialogB = false
      this.refreshList()
    }
  },
  components: {
    VDialog,
    SDialog,
    biddingDialog,
    buttonName
  },
  mounted() {
    this.refreshList()
    this.initBidType()
    this.initBidStatus()
    getRefCodesByType('需求状态').then(res => {
      if (res.success === '1') {
        this.demandStatus = res.data
      }
    })
    getRefCodesByType('运输类型').then(res => {
      if (res.success == 1) {
        this.transportModeList = res.data
      }
    })
    this.searchList()
    this.initBidQuotations()
    let demandWrapper = document.querySelector('.sugarDemand .el-table__body-wrapper')
    // 新增滚动条监听事件
    scrollChange(demandWrapper)
  },
  created() {
    //货物品牌下拉
    // getRefCodesByType('货物品牌').then(res => {
    //   if (res.success === '1') {
    //     res.data.forEach(item => {
    //       this.goodBrands[item.rvLowValue] = item.rvCmeaning
    //     })
    //   }
    // }),
    //品种下拉
    getVarietiesDefaultDropDownSer({
      fltId: store.state.user.FLT_UUID_DX_H,
      dptId: store.state.user.DPTID_DX_H
    }).then(res => {
      if (res.success === '1') {
        res.data.forEach(item => {
          this.$set(this.kinds, item.varCode, item.varName)
        })
        this.kindsDF = res.data[0].varCode
      }
    })
    //货物品牌下拉
    getBrandListDropDownSer({
      fltId: store.state.user.FLT_UUID_DX_H,
      dptId: store.state.user.DPTID_DX_H
    }).then(res => {
      if (res.success === '1') {
        res.data.forEach(item => {
          this.$set(this.goodBrands, item.brandCode, item.brandName)
        })
        this.goodBrandsDF = res.data[0].brandCode
      }
    })
    //货物规格下拉
    getNormListDropDownSer({
      fltUuid: store.state.user.FLT_UUID_DX_H,
      depId: store.state.user.DPTID_DX_H
    }).then(res => {
      if (res.success === '1') {
        res.data.forEach(item => {
          this.$set(this.dailyOutputs, item.normCode, item.normName)
        })
        this.dailyOutputsDF = res.data[0].normCode
      }
    })
    //产品大类下拉
    getProjectBigDropDownSer({
      fltId: store.state.user.FLT_UUID_DX_H,
      dptId: store.state.user.DPTID_DX_H
    }).then(res => {
      if (res.success === '1') {
        res.data.forEach(item => {
          this.$set(this.projuctBigs, item.bcCode, item.bcName)
        })
        this.projuctBigsDF = res.data[0].bcCode
      }
    })
    // //产品大类下拉数据
    // getRefCodesByType('产品大类').then(res => {
    //   if (res.success === '1') {
    //     res.data.forEach(item => {
    //       this.projuctBigs[item.rvLowValue] = item.rvCmeaning
    //     })
    //   }
    // }),

    //产品大类下拉数据
    getRefCodesByType('需求状态').then(res => {
      if (res.success === '1') {
        res.data.forEach(item => {
          this.sfdoStatusS[item.rvLowValue] = item.rvCmeaning
        })
      }
    }),
    //是否回收吊带
    getRefCodesByType('特殊要求').then(res => {
      if (res.success === '1') {
        // specialRequireNames
        // this.specialRequirements=
        res.data.forEach(item => {
          this.specialRequirements[item.rvLowValue] = item.rvCmeaning
        })
      }
    }),
    (this.resize = () => {
      this.typeHeight = this.$refs.topType.offsetHeight - 80
      this.detlHeight = this.$refs.bottomCode.offsetHeight - 60
    })
  },
  watch: {
    selectAllArray(data) {
      this.selectRow = []
      if (data.length > 0) {
        data.forEach((item, index) => {
          this.selectRow.push(this.demandList.indexOf(item))
        })
        console.log('this.selectRow', this.selectRow)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .remarkSP {
  padding-right: 20px;
}
//  ::v-deep .el-table{

//        width:99.9% !important;

// }
//  ::v-deep .el-dialog__body {
//     color: #606266;
//     line-height: 2.4rem;
//     font-size: 1.4rem;
//     padding-top: 0px;
//   }
.app-container {
  overflow: hidden;
  background-color: #fff;
  position: relative;
  height: 100%;
}
.right-detail {
  height: 100%;

  .top-type {
    width: 100%;
    height: 100%;
    // .btn-area{
    //   margin-bottom: 10px;
    // }
    table {
      max-width: 100%;
      font-size: 1.4rem;
    }
  }
  .bottom-code {
    width: 100%;
    height: 100%;
  }
}
.codeNumberCode {
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 40px;
}
.botTable {
  .botTableTitle {
    font-weight: bold;
    padding-left: 10px;
    /*margin-bottom: 10px;*/
    margin-top: -50px;
    margin-bottom: 50px;
    font-size: 15px;
  }
}
</style>
